<%--
  Created by IntelliJ IDEA.
  User: cola
  Date: 2021/4/25
  Time: 20:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>用户列表</h1>
<table>
    <tr>
        <td>id</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${userlist}" var="user">
        <tr>
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.age}</td>
            <td>
                <a href="javascript:void(0)" onclick="deleteById(${user.id})">删除</a>
                <a href="user/${user.id}" <%--onclick="updateById(${user.id})"--%>>修改</a>
            </td>
        </tr>
    </c:forEach>
</table>
<%--<a href="javascript:void(0)" onclick="deleteById()">删除</a>
<a href="javascript:void(0)" onclick="updateById()">修改</a>--%>
<a href="user">增加</a>
<form action="1" method="post" id="deleteForm" hidden>
    <input type="text" name="_method" value="DELETE"readonly>
    <button >DELETE提交</button>
</form>
<form action="1" method="get" id="updateForm" hidden>
    <%--<input type="text" name="_method" value="PUT" readonly>--%>
    <button >PUT提交</button>
</form>
<script>
    function deleteById(id) {
        var form=document.getElementById('deleteForm');
        form.action="user/"+id;
        document.getElementById('deleteForm').submit();
    }
    function updateById(id) {
        var form=document.getElementById('updateForm');
        form.action="user/"+id;
        document.getElementById('updateForm').submit();
    }
    function showdata(date) {
        console.log(date);
    }
</script>
<script src="http://localhost:8080/Mvc02_MVN_war_exploded/users-jsonp?callback=showdata"></script>
</body>
</html>
